package com.alexander.imgbannerwheelview;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.ViewPager;

public class AlphaTransformer implements ViewPager.PageTransformer
{
    private final float MINALPHA = 0.5f;
    @Override
    public void transformPage(@NonNull View page, float position)
    {
        if(position < -1 || position > 1)
        {
            page.setAlpha(MINALPHA);
        }
        else
        {
            if(position < 0)
            {
                page.setAlpha(MINALPHA + (1.f + position) * (1.f - MINALPHA));
            }
            else
            {
                page.setAlpha(MINALPHA + (1.f - position) * (1.f - MINALPHA));
            }
        }
    }
}
